import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from '@/views/admin/login/Login'

Vue.use(VueRouter)

const routes = [
  // 重定向到Home页面
  {
    path: '/',
    redirect: '/login'
  },

  {
    path: '/login',
    name: 'login',
    component: Login
  },

  {
    path: '/home',
    name: 'home',
    component: Home,
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: (resolve) => require(['@/views/Welcome'], resolve)
      },
      {
        path: '/accessLog',
        name: 'accessLog',
        component: (resolve) =>
          require(['@/views/admin/system/AccessLog'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/handleLog',
        name: 'handleLog',
        component: (resolve) =>
          require(['@/views/admin/system/HandleLog'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/menu',
        name: 'menu',
        component: (resolve) => require(['@/views/admin/system/Menu'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/notice',
        name: 'notice',
        component: (resolve) =>
          require(['@/views/admin/system/Notice'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/role',
        name: 'role',
        component: (resolve) => require(['@/views/admin/system/Role'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/user',
        name: 'user',
        component: (resolve) => require(['@/views/admin/system/User'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },

      {
        path: '/interface',
        name: 'interface',
        component: (resolve) =>
          require(['@/views/admin/system/Interface'], resolve),
        meta: {
          headerMenu: 'admin'
        }
      },
      {
        path: '/article',
        name: 'article',
        component: (resolve) =>
          require(['@/views/admin/blog/Article'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/addArticle',
        name: 'addArticle',
        component: (resolve) =>
          require(['@/views/admin/blog/AddArticle'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/classify',
        name: 'classify',
        component: (resolve) =>
          require(['@/views/admin/blog/Classify'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/comment',
        name: 'comment',
        component: (resolve) =>
          require(['@/views/admin/blog/Comment'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/leaveMessage',
        name: 'leaveMessage',
        component: (resolve) =>
          require(['@/views/admin/blog/LeaveMessage'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/link',
        name: 'link',
        component: (resolve) => require(['@/views/admin/blog/Link'], resolve),
        meta: {
          headerMenu: 'article'
        }
      },
      {
        path: '/tag',
        name: 'tag',
        component: (resolve) => require(['@/views/admin/blog/Tag'], resolve),
        meta: {
          headerMenu: 'article'
        }
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
